#pragma once
#include "motion/rtcmds.h"
#include "motion/motion.h"

/*****************************************************************************
 * 设备相关的设置指令
******************************************************************************/

#define RTDEV_SETTING_CMD_CLASS_NAME(x) CMD_CLASS_NAME(x) "[DEVSETTING CMD]"

class CmdShutDown : public mot::RtCmdItf
{
public:
    CmdShutDown() { cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdShutDown); };
    ~CmdShutDown() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };
};

class CmdSetCabvoltage : public mot::RtCmdItf
{
public:
    CmdSetCabvoltage(unsigned int cabVoltage)
    {
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetCabvoltage);
        cabVoltage_ = cabVoltage;
    };
    ~CmdSetCabvoltage() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    unsigned int cabVoltage_;
};

class CmdSetBrStartVoltage : public mot::RtCmdItf
{
public:
    CmdSetBrStartVoltage(int scb_br_start_voltage)
    {
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetBrStartVoltage);
        scb_br_start_voltage_ = scb_br_start_voltage;
    };
    ~CmdSetBrStartVoltage() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int scb_br_start_voltage_;
};

class CmdSetCabinetId : public mot::RtCmdItf
{
public:
    CmdSetCabinetId(double cab_id)
    {
        cab_id_ = cab_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetCabinetId);
    };
    ~CmdSetCabinetId() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    double cab_id_;
};

class CmdSetupIoChannel : public mot::RtCmdItf
{
public:
    CmdSetupIoChannel(int id, int ioType, int channelsetting)
    {
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetupIoChannel);
        id_ = id;
        ioType_ = ioType;
        channelsetting_ = channelsetting;
    };
    ~CmdSetupIoChannel() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int ioType_;
    int channelsetting_;
    int id_;
};

class CmdGetRs485Message : public mot::MultiRobCmd
{
public:
    CmdGetRs485Message(int grp_id, int len, int chn)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdGetRs485Message);
        len_ = len;
        chn_ = chn;
    };
    ~CmdGetRs485Message() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int len_;
    int chn_;
};

class CmdSetTioRs485SigProgStat : public mot::MultiRobCmd
{
public:
    CmdSetTioRs485SigProgStat(int grp_id, const char* sig_name, int prog_stat)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetTioRs485SigProgStat);
        for (int i = 0; i < 128; i++) { sig_name_[i] = sig_name[i]; }
        prog_stat_ = prog_stat;
    };
    ~CmdSetTioRs485SigProgStat() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    char sig_name_[128];
    int prog_stat_;
};

class CmdSetmodeTorqsensor : public mot::MultiRobCmd
{
public:
    CmdSetmodeTorqsensor(int grp_id, double mode)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetmodeTorqsensor);
        mode_ = mode;
    };
    ~CmdSetmodeTorqsensor() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    double mode_;
};

class CmdSetbrandTorqsensor : public mot::MultiRobCmd
{
public:
    CmdSetbrandTorqsensor(int grp_id, int torqsensorBrand)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetbrandTorqsensor);
        torqsensorBrand_ = torqsensorBrand;
    };
    ~CmdSetbrandTorqsensor() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int torqsensorBrand_;
};

class CmdSetcommTorqsensor : public mot::MultiRobCmd
{
public:
    CmdSetcommTorqsensor(int grp_id, CommInfo commCfg, int type)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetcommTorqsensor);
        commCfg_ = commCfg;
        type_ = type;
    };
    ~CmdSetcommTorqsensor() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    CommInfo commCfg_;
    int type_;
};

class CmdTioSetRs485ChnMode : public mot::MultiRobCmd
{
public:
    CmdTioSetRs485ChnMode(int grp_id, int mode, int chnId)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdTioSetRs485ChnMode);
        mode_ = mode;
        chnId_ = chnId;
    };
    ~CmdTioSetRs485ChnMode() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int mode_;
    int chnId_;
};

class CmdTioSetRs485ChnComm : public mot::MultiRobCmd
{
public:
    CmdTioSetRs485ChnComm(int grp_id, const ModRtuComm& rtuComm, int chnId)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdTioSetRs485ChnComm);
        rtuComm_ = rtuComm;
        chnId_ = chnId;
    };
    ~CmdTioSetRs485ChnComm() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    ModRtuComm rtuComm_;
    int chnId_;
};

class CmdTioSetPinMode : public mot::MultiRobCmd
{
public:
    CmdTioSetPinMode(int grp_id, int mode, int type)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdTioSetPinMode);
        mode_ = mode;
        type_ = type;
    };
    ~CmdTioSetPinMode() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int mode_;
    int type_;
};

class CmdTioSetVoutEna : public mot::MultiRobCmd
{
public:
    CmdTioSetVoutEna(int grp_id, int enable)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdTioSetVoutEna);
        enable_ = enable;
    };
    ~CmdTioSetVoutEna() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int enable_;
};

class CmdTioSetVoutVol : public mot::MultiRobCmd
{
public:
    CmdTioSetVoutVol(int grp_id, double voltage)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdTioSetVoutVol);
        voltage_ = voltage;
    };
    ~CmdTioSetVoutVol() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int voltage_;
};

class CmdServoUpgrade : public mot::MultiRobCmd
{
public:
    CmdServoUpgrade(int grp_id)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdServoUpgrade);
    };
    ~CmdServoUpgrade() {}

    virtual int active_callback() { return -1; };
    virtual int process();
    virtual int check_para() { return 0; };
};

class CmdSetFreeButtonOpt : public mot::MultiRobCmd
{
public:
    CmdSetFreeButtonOpt(int grp_id, int option)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetFreeButtonOpt);
        option_ = option;
    };
    ~CmdSetFreeButtonOpt() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int option_;
};

class CmdSetPointButtonOpt : public mot::MultiRobCmd
{
public:
    CmdSetPointButtonOpt(int grp_id, int option)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetPointButtonOpt);
        option_ = option;
    };
    ~CmdSetPointButtonOpt() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int option_;
};

class CmdSetFreeProgButtonOpt : public mot::MultiRobCmd
{
public:
    CmdSetFreeProgButtonOpt(int grp_id, int progOpt, int freeOpt)
    {
        group_id_ = grp_id;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdSetFreeProgButtonOpt);
        progOpt_ = progOpt;
        freeOpt_ = freeOpt;
    };
    ~CmdSetFreeProgButtonOpt() {}

    virtual int active_callback() { return 0; };
    virtual int process();
    virtual int check_para() { return 0; };

    int progOpt_;
    int freeOpt_;
};

class CmdRobotPowerOn : public mot::MultiRobCmd
{
public:
    CmdRobotPowerOn(int robid, uint8_t busid, uint8_t busdev_start_id, uint8_t axis_start_id)
    {
        group_id_ = robid;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdRobotPowerOn);
        busid_ = busid;
        busdev_start_id_ = busdev_start_id;
        axis_start_id_ = axis_start_id;
        cmd_name_ = "CmdRobotPowerOn";
    }

    virtual int active_callback();
    virtual int process();

    uint8_t busid_;
    uint8_t busdev_start_id_;
    uint8_t axis_start_id_;
};

class CmdRobotAxisBoot : public mot::MultiRobCmd
{
public:
    CmdRobotAxisBoot(int grpid)
    {
        group_id_ = grpid;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdRobotAxisBoot);
    }

    virtual int active_callback() { return 0; };
    virtual int process();
};

class CmdRobotBoot : public mot::MultiRobCmd
{
public:
    CmdRobotBoot(int grpid)
    {
        group_id_ = grpid;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdRobotBoot);
    }
    virtual int active_callback() { return 0; };
    virtual int process();
};

class CmdPowerOffRobot : public mot::MultiRobCmd
{
public:
    CmdPowerOffRobot(int robid)
    {
        group_id_ = robid;
        cmd_name_ = RTDEV_SETTING_CMD_CLASS_NAME(CmdPowerOffRobot);
    }

    virtual int active_callback();
    virtual int process();
};